﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RenderEngineInterfaces;
using DeepZoomPivotConstructor.VisualLib;
using System.ComponentModel.Composition;
using System.Threading.Tasks;

namespace ArxivRenderer
{
    /// <summary>
    /// We are not allowed to go after arxiv stuff directly - so this guy just zero's out those requests.
    /// </summary>
    [Export(typeof(IRenderItem))]
    [RenderInfo(typeof(Uri))]
    public class RenderArxivUri : IRenderItem
    {
        /// <summary>
        /// We always render to nothing - no slides, no nothing. We are going to swallow this guy!
        /// </summary>
        /// <param name="what"></param>
        /// <returns></returns>
        public Task<Visual> Render(object what)
        {
            return Task<Visual>.Factory.StartNew(() => new VisualHolder());
        }

        /// <summary>
        /// When we get a uri that points to what we thing it should point to, we go!
        /// </summary>
        /// <param name="what"></param>
        /// <returns></returns>
        public RenderPluginPriority RenderPriority(object what)
        {
            var u = what as Uri;
            if (u == null)
                return RenderPluginPriority.RPPCantDoIt;

            if (u.OriginalString.Contains("arxiv.org"))
                return RenderPluginPriority.RPPSpecific;
            return RenderPluginPriority.RPPCantDoIt;
        }
    }
}
